package com.skt.controller;

import com.skt.domain.VO.BloomFilterStatsVO;
import com.skt.domain.VO.BloomFilterHealthVO;
import com.skt.service.BloomFilterService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 布隆过滤器监控控制器
 */
@Tag(name = "布隆过滤器监控", description = "布隆过滤器状态监控接口")
@RestController
@RequestMapping("/monitor")
@RequiredArgsConstructor
public class BloomFilterMonitorController {

    private final BloomFilterService bloomFilterService;

    @Operation(summary = "获取布隆过滤器统计信息")
    @GetMapping("/bloomfilter/stats")
    public BloomFilterStatsVO getBloomFilterStats() {
        return bloomFilterService.getStats();
    }

    @Operation(summary = "检查布隆过滤器健康状态")
    @GetMapping("/bloomfilter/health")
    public BloomFilterHealthVO getBloomFilterHealth() {
        return bloomFilterService.checkHealth();
    }

    @Operation(summary = "重置布隆过滤器（管理员用）")
    @GetMapping("/bloomfilter/reset")
    public String resetBloomFilter() {
        // 注意：生产环境慎用，需要权限控制
        bloomFilterService.initBloomFilter();
        return "布隆过滤器重置成功";
    }
}